﻿/*  ----------------------------------------------------------------------------
 *  RuleCode.Inc
 *  ----------------------------------------------------------------------------
 *  Object Template Engine
 *  ----------------------------------------------------------------------------
 *  File:       Util.cs
 *  Author:     RULECODE\yangbo
 *  Create Date:12-22-2009
 *  ----------------------------------------------------------------------------
 */
#region Using directives

using System;
using System.Collections.Generic;
using System.Text;

#endregion

namespace RuleCode.TemplateEngine
{
	public static class Util
	{
		public static bool ToBool(object obj)
		{
			if (obj is bool)
				return (bool)obj;
			else if (obj is string)
			{
				string str = (string)obj;
				if (string.Compare(str, "true", true) == 0)
					return true;
				else if (string.Compare(str, "yes", true) == 0)
					return true;
				else
					return false;
			}
			else
				return false;
		}
	}
}